#include "PopupThreadInvitationMsg.hpp"

using namespace std;
using namespace Popup;

ThreadInvitationMsg::ThreadInvitationMsg(const Message *p_message)
: AbstractMessage(POPUP_MSG_TYPE_INVITATION)
{
  AbstractMessage::deserialize(p_message);
}

bool ThreadInvitationMsg::onSend()
{
  bool _rc = payloadAddLongLong(THREAD_ID, threadID);

  if (_rc) {
    payloadAddLong(INVITER_ID, inviter);
  }
  if (_rc) {
    _rc = payloadAddLong(CC_TARGETS, cc);
  }
  if (_rc) {
    payloadAddString(THREAD_TITLE, threadTitle);
  }
  if (_rc) {
    payloadAddLong(INVITED_USERS_ID, invitedUsers);
  }

  return _rc;
}

bool ThreadInvitationMsg::onReceive()
{
  bool _rc = payloadGetLongLong(THREAD_ID, threadID);

  if (_rc) {
    _rc = payloadGetLong(CC_TARGETS, cc);
  }
  if (_rc) {
    _rc = payloadGetLong(INVITER_ID, inviter);
  }
  if (_rc) {
    payloadGetString(THREAD_TITLE, threadTitle);
  }
  if (_rc) {
      payloadGetLong(INVITED_USERS_ID, invitedUsers);
    }

  return _rc;
}
